#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<time.h>
int main(int argc,const char* argv[]){
    if(argc != 3){
        return -1;
    }
    FILE*fp = fopen(argv[2],"r");
    if(fp == NULL){
        printf("fopen err\n");
        return -1;
    }
    printf("________fopen success_______\n");


//打印
    size_t temp=0;
    int n=0;
    n-=atoi(argv[1]);
    if(n <= 0){
        return -1;
    }
    char ch[32]={0};
    while(n){
        temp =fread(ch,1,32,fp);
        if( temp > 0){
            for(int i=0;i<temp;i++){
                printf("%c",ch[i]);
                if(ch[i] == '\n'){
                    n--;
                }
                if(n == 0){
                    break;
                }
            }
        }else{
            n--;
        }
    }


    if(ferror(fp)){
        perror("err");
    }else if(feof(fp)){
        printf("_______end of file_______\n");
    }

    fclose(fp);
    fp=NULL;
    return 0;
}